package com.company;
//定义一个宠物的标准
interface Pet {
    public String getName();
    public int getAge();
}
//定义宠物商店
class PetShop{
    private Link pets=new Link();
    public void add(Pet pet) {
        this.pets.add(pet);
    }
    //删除宠物信息
    public void delete(Pet pet){
        this.pets.remove(pet);
    }
    //查询到了宠物信息，保存结果
    public Link search(String keyWord){
        Link result=new Link();
        Object obj[]=this.pets.toArray();
        for (int x=0;x<obj.length;x++){
            Pet p=(Pet) obj[x];
            if (p.getName().contains(keyWord)){
                result.add(p);
            }
        }
        return result;
    }
}

